home *** CD-ROM | disk | FTP | other *** search
- Path: news.eden.com!usenet
- From: Shane Sadler <nexus@eden.com>
- Newsgroups: comp.lang.c
- Subject: Re: c++ and readability
- Date: Wed, 14 Feb 1996 19:20:34 -0700
- Organization: Eden Matrix Services
- Message-ID: <31229872.2A980200@eden.com>
- References: <DMoyuG.CD4@world.std.com>
- NNTP-Posting-Host: net-3-030.austin.eden.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; Linux 1.2.8 i586)
-
- bender wrote:
- >
- > Its disappointing to me that us C programmers haven't yet developed a
- > standard, readable style of writing code.
- > I find it almost impossible to read other peoples code, merely because of
- > their style of using tabs, spaces, and putting the { delimeter at the end
- > of the line.
- >
- > (This is actually Java code, but its good enough to prove my point)
- >
- > Now I ask you which is more readable, this:
- >
- > if (startImage > endimage) {
- > for (int i = startImage; i >= endImage; i--) {
- > result.addElement(new URL(imageSource, "T"+i+".gif"));
- > }
- > } else if (sounds != null) {
- > badURL = fetchSounds(sounds);
- > if (badURL != null) {
- > loadError(badURL, soundLabel);
- > return;
- > }
- > }
- >
- >
- > This is chaos, how do you know
- > or this:
- >
- > if (startImage > endImage)
- > {
- > for (int i = startImage; i >= endImage; i--)
- > {
- > result.addElement(new URL(imageSource, "T"+i+".gif"));
- > }
- > }
- > else if (sounds != null)
- > {
- > badURL = fetchSounds(sounds);
- > if (badURL != null)
- > {
- > loadError(badURL, soundLabel);
- > return;
- > }
- > }
- >
- >
- > Almost all code I see by other programmers is like the first example. Now
- > am I nuts, is it just me that thinks its hard to read?
-
- Well, I can read both of them, but as far as preferences, I prefer the
- style I use....Why is that not surprising?....which is something in
- between your two examples. But that's just when I'm doing stuff at home.
- I think it would be irresponsible of me to use anything but the One True
- Brace Style (of K&R fame) for coding at work. It's readable and widely
- used and isn't it one of Henry Spencer's Ten Commmandments? I don't find
- OTBS as aesthetically pleasing (for whatever that's worth), but whoever
- ends up maintaining/fixing my code won't be taking my name in vain quite
- as much. Besides, while I haven't used one, aren't there C "beautifiers"
- out there that you can configure to your favorite style?
-
- -- Shane
- ===================================================================
- S. M. Sadler
- e-mail: nexus@eden.com
- Web: http://www.eden.com/~nexus
-